//
//  UIColor+Custom.m
//  YUKI
//
//  Created by Jewelz on 16/9/1.
//  Copyright © 2016年 Jewelz. All rights reserved.
//

#import "UIColor+Custom.h"

@implementation UIColor (Custom)

/**
 *  16进制转换成color
 *
 *   param stringToConvert 字体的颜色值
 *
 *   return UIColor
 */
+ (UIColor *)colorWithHexString:(NSString *) stringToConvert
{
    NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    if ([cString length] < 6)
        return [UIColor whiteColor];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];
    if ([cString length] != 6)
        return [UIColor whiteColor];
    
    NSRange range;
    range.location = 0;
    range.length = 2;
    NSString *rString = [cString substringWithRange:range];
    
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    
    return [UIColor colorWithRed:((float) r / 255.0f)
                           green:((float) g / 255.0f)
                            blue:((float) b / 255.0f)
                           alpha:1.0f];
}

/**
 *  主题色
 *
 *   return color
 */
+ (UIColor *)themeColor
{
    return [UIColor colorWithHexString:@"#1fa2f2"];
}
/**
 成功的绿色
 
 @return color
 */
+ (UIColor *)successfulColor{
    return [UIColor colorWithHexString:@"#4BD964"];

}
/**
 *  分割线颜色
 *
 *   return color
 */
+ (UIColor *)separateLineColor
{
    return [UIColor colorWithHexString:@"#e1e1e1"];
}
/**
 *   按钮轮廓颜色
 *
 *   return color
 */
+ (UIColor *)buttonOutlineColor
{
    return [UIColor colorWithHexString:@"#e1e1e1"];
}

/**
 *   头部按钮底线颜色
 *
 *   return color
 */
+ (UIColor *)navcBottomLineColor
{
    return [UIColor colorWithHexString:@"#e1e1e1"];
}
/**
 *  文字偏黑色
 *
 *   return color
 */
+ (UIColor *)textBlackColor{
    return [UIColor colorWithHexString:@"#484848"];
}

/**
 文字灰色

 @return color
 */
+ (UIColor *)textGrayColor{
    return [UIColor colorWithHexString:@"#858585"];
}
/**
 文字浅灰色
 
 @return color
 */
+ (UIColor *)textLightGrayColor{
    return [UIColor colorWithHexString:@"#bdbdbd"];
}

/**
 随机色

 @return color
 */
+ (UIColor *)randomColor{
    return [UIColor colorWithRed:arc4random_uniform(255) / 255.0 green:arc4random_uniform(255) / 255.0 blue:arc4random_uniform(255) / 255.0 alpha:1];
}

/**
 微信色
 
 @return color
 */
+ (UIColor *)WXColor{
    return [UIColor colorWithHexString:@"#2aa84a"];
}
/**
 支付宝色
 
 @return color
 */
+ (UIColor *)AlipayColor{
    return [UIColor colorWithHexString:@"#1E95D4"];
}
/**
 美团色
 
 @return color
 */
+ (UIColor *)meituanColor{
    return [UIColor colorWithHexString:@"#25B7AA"];
}
/**
 大众色
 
 @return color
 */
+ (UIColor *)dazhongColor{
    return [UIColor colorWithHexString:@"#F39800"];
}

/**
 百度糯米色

 @return color
 */
+ (UIColor *)ruomise{
    return [UIColor colorWithHexString:@"#E73274"];
}

/**
 传入分类ID获取颜色

 @param buytypeid 支付宝 微信 大众 美团  糯米
 @return 颜色
 */
+ (UIColor *)getTypecolorWithTypeID:(NSInteger)buytypeid{
    
    switch (buytypeid) {
        case 4:
            return [UIColor WXColor];
        case 5:
            return [UIColor AlipayColor];
        case 6:
            return [UIColor dazhongColor];
        case 7:
            return [UIColor meituanColor];
        case 14:
            return [UIColor ruomise];
        default:
            return nil;
            break;
    }
}

@end
